package com.wjs.juc.Atmoic;

import java.util.concurrent.atomic.LongAccumulator;
import java.util.concurrent.atomic.LongAdder;

public class LongAdderDemo {
    public static void main(String[] args) {
        LongAccumulator accumulator = new LongAccumulator((x, y) -> {
            return x * y;
        }, 1);
        accumulator.accumulate(2);
        accumulator.accumulate(2);
        accumulator.accumulate(2);

        System.out.println(accumulator.get());
    }

    private static void longAddr() {
        LongAdder longAdder = new LongAdder();
        longAdder.increment();
        longAdder.increment();
        longAdder.increment();

        System.out.println(longAdder.sum());
    }
}
